package forumSystem;

import java.util.TreeMap;
import java.util.Vector;
//import protocol.Notification;

public class ForumNotifications {
	
	private static TreeMap<Integer, Vector<Notification> > forumNotificationsBinds = new TreeMap<Integer, Vector<Notification>>();
	
	
	public static void addBind(int forumId, Vector<Notification> notifications)
	{
		if(notifications != null)
			forumNotificationsBinds.put(forumId, notifications);
	}

	public static void removeBind(int forumId)
	{
		forumNotificationsBinds.remove(forumId);
	}
	
	public static Vector<Notification> getNotifications(int forumId)
	{
		Vector<Notification> vn = forumNotificationsBinds.get(forumId);
		if(vn == null)
			return new Vector<Notification>();
		else 
			return vn;
	}
	
	public static void addNotification(int forumId, Notification n, boolean push)
	{
		if(n != null )
		{
				Vector<Notification> v = forumNotificationsBinds.get(forumId);
				if(v != null)
					v.add(n);
				else
				{
					v = new Vector<Notification>();
					v.add(n);
				}
				forumNotificationsBinds.put(forumId,v);
				
				if(!push)
					ForumNotifier.get(forumId).notify();
			
		}
	}
	
}
